package com.channelsharing.hongqu.portal.api.service.impl;

import com.channelsharing.common.service.CrudServiceImpl;
import com.channelsharing.hongqu.portal.api.dao.UserCouponDao;
import com.channelsharing.hongqu.portal.api.entity.UserCoupon;
import com.channelsharing.hongqu.portal.api.enums.UserCouponStatus;
import com.channelsharing.hongqu.portal.api.service.UserCouponService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserCouponServiceImpl extends CrudServiceImpl<UserCouponDao,UserCoupon> implements UserCouponService {

    @Override
    public UserCoupon findOne(Long id) {
        return null;
    }

    @Override
    public List<UserCoupon> findListByCouponId(Long couponId) {
        UserCoupon userCoupon = new UserCoupon();
        userCoupon.setCouponId(couponId);
        userCoupon.setStatus(UserCouponStatus.unused.getCode());
        return super.dao.findList(userCoupon);
    }

    @Override
    public List<UserCoupon> findByUserIdAndStatus(Long userId,Integer status) {
        UserCoupon userCoupon = new UserCoupon();
        userCoupon.setUserId(userId);
        userCoupon.setStatus(status);
        return super.dao.findList(userCoupon);
    }

    @Override
    public List<UserCoupon> findByUserIdAndCouponId(Long userId, Long couponId) {
        UserCoupon userCoupon = new UserCoupon();
        userCoupon.setUserId(userId);
        userCoupon.setStatus(UserCouponStatus.unused.getCode());
        userCoupon.setCouponId(couponId);
        return super.dao.findList(userCoupon);
    }

}
